package com.eclipse.e0112_jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class jdbc_throws {

	public static void main(String[] args) throws Exception {

		// 加载驱动
//		Class.forName("com.mysql.cj.jdbc.Driver");

		// 打开链接
		Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test1", "root", "qq123123");

		PreparedStatement statement = connection.prepareStatement("select * from grade");//PreparedStatement防止sql注入 传值用?

		ResultSet resultSet = statement.executeQuery();
		// 删除 更新 增加 sta.executeUpdate();

		while (resultSet.next()) {//判断是否有下一行
			System.out.println(resultSet.getString("subject"));//get类型.("列名") 类型String 或者int
		}
	}
}
